from django.contrib.auth.models import Group, Permission
from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet

from meiduo_admin.serializer.group import GroupSerializer, PermissionSerializer
from meiduo_admin.utils import UserPageNum


class UserGroupView(ModelViewSet):

    #接收分页器
    pagination_class = UserPageNum
    # 指明序列化器
    serializer_class = GroupSerializer
    # 指明查询集
    queryset = Group.objects.all()

    # 获取权限表数据
    def simple(self,request):

        pers = Permission.objects.all()
        ser = PermissionSerializer(pers,many=True)
        return Response(ser.data)



